﻿using RJCP.IO.Ports;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace UDIServer
{
    /// <summary>
    /// 串口通信类
    /// </summary>
    public class ComHelper
    {
        SerialPortStream serialPort = null;

        public ComHelper(ComConfig config)
        {
            //配置串口参数
            serialPort = new SerialPortStream(config.Port.ToUpper(), config.Baud, 8, Parity.None, StopBits.One);
            serialPort.Handshake = Handshake.None;
            serialPort.RtsEnable = true;
        }
    }

    public class ComConfig
    {
        public string Port { get; set; }

        public int Baud { get; set; } = 9600;
    }
}
